﻿using GenericRepositoryDemo.Domain.Abstracts.Entites;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;

namespace GenericRepositoryDemo.Domain.Abstracts.Repositories;

public interface IRepository
{

}

public interface IRepository<TEntity, TKey> : IRepository
    where TEntity : class, IEntity<TKey>
{
    Task<TEntity> GetAsync(TKey id);
    Task<TEntity> GetAsync([NotNull] Expression<Func<TEntity, bool>> predicate);
    Task<TEntity> FindAsync(TKey id);
    Task<TEntity> FindAsync([NotNull] Expression<Func<TEntity, bool>> predicate);
    Task<List<TEntity>> GetListAsync();
    Task<List<TEntity>> GetListAsync([NotNull] Expression<Func<TEntity, bool>> predicate);
    Task<List<TEntity>> GetPagedListAsync(int skipCount, int maxResultCount, string sorting);
    Task<long> GetCountAsync();

    Task<TEntity> InsertAsync([NotNull] TEntity entity, bool autoSave = false);
    Task InsertManyAsync([NotNull] IEnumerable<TEntity> entities, bool autoSave = false);

    Task<TEntity> UpdateAsync([NotNull] TEntity entity, bool autoSave = false);
    Task UpdateManyAsync([NotNull] IEnumerable<TEntity> entities, bool autoSave = false);

    Task DeleteAsync(TKey id, bool autoSave = false);
    Task DeleteAsync([NotNull] TEntity entity, bool autoSave = false);
    Task DeleteAsync([NotNull] Expression<Func<TEntity, bool>> predicate, bool autoSave = false);
    Task DeleteManyAsync([NotNull] IEnumerable<TEntity> entities, bool autoSave = false);
    Task DeleteManyAsync([NotNull] IEnumerable<TKey> ids, bool autoSave = false);

    Task SaveChangesAsync();
    Task<IQueryable<TEntity>> WithDetailsAsync(params Expression<Func<TEntity, object>>[] propertySelectors);
    Task<IQueryable<TEntity>> GetQueryableAsync();
}